package com.bailan.foreat.mapper;

import com.bailan.foreat.entity.Item;
import com.bailan.foreat.vo.ItemVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ste
 * @since 2023-02-21 07:50:43
 */
@Mapper
public interface ItemMapper extends BaseMapper<Item> {
    @Select("SELECT i.id ,i.product_id productId ,i.product_name productName ,i.store_id storeId ,i.price ,i.buy_count buyCount ,i.sum_price sumPrice ,i.user_id userId ,i.order_id orderId ,i.status ,p.product_img productImg \n" +
            "FROM t_item i INNER JOIN t_product p\n" +
            "ON i.product_id=p.id " +
            "WHERE i.id=#{itemId}")
    ItemVo selectItemVo(Integer itemId);

    @Select("SELECT i.id ,i.product_id productId ,i.product_name productName ,i.store_id storeId ,i.price ,i.buy_count buyCount ,i.sum_price sumPrice ,i.user_id userId ,i.order_id orderId ,i.status ,p.product_img productImg \n" +
            "FROM t_item i INNER JOIN t_product p\n" +
            "ON i.product_id=p.id " +
            "WHERE i.order_id=#{orderId} " +
            "AND i.store_id=#{storeId}")
    List<ItemVo> selectItemListOfOrderItem(Integer orderId,Integer storeId);
}
